package com.enation.app.javashop.core.client.fallback.member;

import com.enation.app.javashop.core.client.feignimpl.member.MemberAddressClientFeigntImpl;
import com.enation.app.javashop.core.handler.BaseFallbackFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.enation.app.javashop.model.member.dos.MemberAddress;
import org.springframework.stereotype.Component;

/**
 * 会员地址熔断fallback factory
 * @author kingapex
 * @version 1.0
 * @data 2022/5/28 14:25
 **/
@Component
public class MemberAddressClientFallbackFactory  extends BaseFallbackFactory<MemberAddressClientFeigntImpl> {
    @Override
    protected MemberAddressClientFeigntImpl fallback() {
        return new MemberAddressClientFallback();
    }

    /**
     * 会员地址熔断
     *
     * @author zh
     * @version v7.0
     * @date 18/9/27 下午3:27
     * @since v7.0
     */
    @Component
    public static class MemberAddressClientFallback implements MemberAddressClientFeigntImpl {

        private final Logger logger = LoggerFactory.getLogger(getClass());

        @Override
        public MemberAddress getModel(Long id) {
            logger.error("获取ID为" + id + "的地址错误");
            return null;
        }

        @Override
        public MemberAddress getDefaultAddress(Long memberId) {
            logger.error("获取会员ID为" + memberId + "的默认地址错误");
            return null;
        }
    }
}
